package com.itboye.eweilisten.me.personal.activity;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.eweilisten.R;
import com.itboye.eweilisten.base.BaseActivity;
import com.itboye.eweilisten.model.FeedbackBean;
import com.itboye.eweilisten.util.widget.MyGridView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by itboye on 2017/4/19.
 */

public class FeedBackActivity extends BaseActivity {
    private String title;
    private ImageView back;
    private TextView tvTitle;
    private MyGridView myFeedBackGridview;
    private MyFeedBakAdapter adapter;
    List<FeedbackBean> list;
    String name[] = {"反馈建议","用户协议", "用户协议", "用户协议", "用户协议", "用户协议", "用户协议", "用户协议"};

    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        //让布局向上移来显示软键盘
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        setContentView(R.layout.activity_feed_back);
        init();
    }

    public void init() {
        title = getIntent().getStringExtra("title");
        tvTitle.setText(title);
        list = new ArrayList<>();
        FeedbackBean bean = new FeedbackBean();
        for (int i = 0; i < name.length; i++) {
            bean.setName(name[i]);

            list.add(bean);
        }
        Log.d("beanbeanbean", bean.getName() + "");

        adapter = new MyFeedBakAdapter(this,list);
        myFeedBackGridview.setAdapter(adapter);
        myFeedBackGridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        });
    }

    public class MyFeedBakAdapter extends BaseAdapter {
        Context context;
        List<FeedbackBean> list;
        public int now=0;//上一次选中的pos
        private boolean isFlag=true;

        public MyFeedBakAdapter(Context context, List<FeedbackBean> list) {
            this.context = context;
            this.list=list;
        }

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHouder houder = null;
            if (convertView == null) {
                houder = new ViewHouder();
                convertView = LayoutInflater.from(context).inflate(R.layout.item_feed_back, null);
                houder.title = (TextView) convertView.findViewById(R.id.tvFankui);
                convertView.setTag(houder);
            } else {
                houder = (ViewHouder) convertView.getTag();
            }
            Log.d("positionposition",list.get(position).getName()+"");
            houder.title.setText(list.get(position).getName());
            return convertView;
        }

        public class ViewHouder {
            TextView title;
        }
    }

}